package org.xiji.command;

import java.util.ArrayList;
import java.util.List;

/**
 *  命令模式
 */
public class CommandMain {
    public static void main(String[] args) {

        //创建角色
        GameRole zhangsan = new GameRole("张三");
        GameRole lisi = new GameRole("李四");
        GameRole xiaojiu = new GameRole("小久");
        GameRole xiji = new GameRole("惜己");

        //封装角色指令
        GameRoleCommand zhangsanCommand = new GameRoleCommand(zhangsan);
        GameRoleCommand lisiCommand = new GameRoleCommand(lisi);
        GameRoleCommand xiaojiuCommand = new GameRoleCommand(xiaojiu);
        GameRoleCommand xijiCommand = new GameRoleCommand(xiji);

        //创建指令队列
        ArrayList<GameRoleCommand> gameRoleCommandMQ = new ArrayList<>();
        gameRoleCommandMQ.add(zhangsanCommand);
        gameRoleCommandMQ.add(lisiCommand);
        gameRoleCommandMQ.add(xiaojiuCommand);
        gameRoleCommandMQ.add(xijiCommand);

        //执行角色指令队列

        for (int i = 0; i < gameRoleCommandMQ.size(); i++) {
            System.out.println("================================================================");
            System.out.println("总共"+gameRoleCommandMQ.size()+"指令."+"现在执行"+(i+1)+"指令");
            //使用指令，指令的执行模式
            gameRoleCommandMQ.get(i).firstSkill();
            gameRoleCommandMQ.get(i).secondSkill();
            gameRoleCommandMQ.get(i).thirdSkill();
            gameRoleCommandMQ.get(i).fourthSkill();
            System.out.println("================================================================");
        }


    }
}
